package models

import "gorm.io/gorm"

type Cart struct {
	gorm.Model
	Title  string  `gorm:"type:varchar(30);not null;comment:标题"`
	Image  string  `gorm:"type:varchar(100);not null;comment:图片"`
	Price  float64 `gorm:"type:decimal(10,2);not null;comment:价格"`
	Desc   string  `gorm:"type:varchar(50);not null;comment:简介"`
	Status int     `gorm:"type:int(11);not null;default:1;comment:状态"`
}

func (c *Cart) Create() error {
	return DB.Debug().Create(&c).Error
}
func (c *Cart) List() (cartList []*Cart, err error) {
	err = DB.Debug().Where("status = 1").Find(&cartList).Error
	return
}
